import axios from 'axios'
import store from './store'
import router from './router'
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    config.headers.Token = store.state.token || ''
    return config
},function (error) {
    return Promise.reject(error)
})
// 添加响应拦截器
axios.interceptors.response.use(function (response) {
    // 对响应数据做点什么
    return response
},function (error) {
    if (error.response.status === 401) {
        router.push({
            name: 'Login'
        })
    }
    return Promise.reject(error)
})
export default axios;